package com.gaga.console.core.service.impl;

import com.gaga.common.constant.BvConstants;
import com.gaga.common.enums.DelFlag;
import com.gaga.common.utils.CommonPathUtils;
import com.gaga.console.base.mybatisplus.LambdaQueryWrapperExt;
import com.gaga.console.core.entity.SysConfig;
import com.gaga.console.core.entity.SysDict;
import com.gaga.console.core.mapper.SysConfigMapper;
import com.gaga.console.core.service.SysConfigService;
import com.gaga.console.base.service.impl.SuperServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 用户信息表 服务实现类
 * </p>
 *
 * @author liujia
 * @since 2025-03-27
 */
@Service
@Slf4j
public class SysConfigServiceImpl extends SuperServiceImpl<SysConfigMapper, SysConfig> implements SysConfigService {

    @Override
    public SysConfig getByConfigKey(String configKey) {

        LambdaQueryWrapperExt<SysConfig> wraps = new LambdaQueryWrapperExt<>();
        wraps.eq(SysConfig::getConfigKey, configKey);

        return getOne(wraps);
    }

    @Override
    public String getConfigValueByKey(String configKey) {
        SysConfig sysConfig = getByConfigKey(configKey);
        if (sysConfig == null || StringUtils.isBlank(sysConfig.getConfigValue())) {
            return "";
        }

        return sysConfig.getConfigValue();
    }

    @Override
    public String getAbsolutePathByKey(String configKey) {
        String path = getConfigValueByKey(configKey);
        log.info("=================dir=" + CommonPathUtils.getBasePath() + path);
        return CommonPathUtils.getBasePath() + path;
    }
}
